package com.vend.user.home

import android.os.Build
import android.os.Bundle
import android.util.Log
import android.view.View
import android.view.ViewGroup
import android.webkit.WebResourceRequest
import android.webkit.WebView
import androidx.annotation.RequiresApi
import com.alibaba.android.arouter.facade.annotation.Route
import com.vend.common.base.BaseWebFragment
import com.vend.common.base.model.FragmentType
import com.vend.common.constant.RouterConstant
import com.vend.common.mvp.IPresenter
import com.vend.user.R
import kotlinx.android.synthetic.main.fragment_user_home.*

/**
 * Created by glendal on 2022/01/25.
 * 当前界面是模拟我的中界面嵌套网页的逻辑i
 */
@Route(path = RouterConstant.USER_HOME)
class UserFragment : BaseWebFragment<IPresenter>() {
    override fun initView(view: View, savedInstanceState: Bundle?) {
    }

    override fun getContentViewId(): Int {
        return R.layout.fragment_user_home
    }

    override fun lazyInit() {
        super.lazyInit()
        //这里将类型设置进去
        setFragmentType(FragmentType.Fragment_Self.fType)
    }

    override fun getUrl(): String? {
        return "https://www.baidu.com/"
    }
    override fun getAgentWebParent(): ViewGroup {
        return contain_web
    }

    @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
    override fun shouldLoadingUrl(view: WebView?, request: WebResourceRequest?): Boolean {
        val detailUrl = request?.url.toString()
        Log.e("tag", "url  $detailUrl")
        return false
//        if (detailUrl.startsWith("openapp")){
//            return false
//        }
//        //这里跳转到详情中去 通过ARouter
////        val inten = Intent(mSelf,DetailActivity::class.java)
////        inten.putExtra(DetailActivity.URL_STRING,detailUrl)
////        mSelf.startActivity(inten)
//        return true
    }

}